package servlet_test;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class HelloServlet implements Servlet {
    public HelloServlet() {
        System.out.println("我是构造器");
    }
    @Override
    public void init(javax.servlet.ServletConfig servletConfig) throws ServletException {
        String name = servletConfig.getServletName();
        System.out.println("初始化。。。");
        System.out.println("HelloServlet程序别名："+name);
        System.out.println("初始化参数username："+servletConfig.getInitParameter("username"));
        System.out.println("初始化参数url"+servletConfig.getInitParameter("url"));
    }

    @Override
    public javax.servlet.ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("Hello Servlet被访问了");
        HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
        String method = httpServletRequest.getMethod();
        System.out.println("你的请求方式为："+method);
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("销毁中。。。。");
    }

}

